﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Text;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System.IO;
using ReflectionStudio.Core;
using INTEX.DataBase;
using INTEX.DataBase.Tools;
namespace WPFExcelReport
{
    public partial class JLTONAV95Data
    {
        SETINTEXDB INTEXDB = new SETINTEXDB();
        INTEXDBC INTEXDBC;
        public DataRow GetProcessFlow(string stage, string art, string var, string color, string matchid)
        {
            DataRow row = null;
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            string expression = "";
            expression = "STAGE='" + stage + "' AND MATCHID='" + matchid + "'";
            DataRow[] rows = SetDispo.Tables["DATADISPO"].Select(expression);
            if (rows.Length > 0)
            {
                row = rows[0];
            }
            return row;
        }
        public DataSet GetAPZUORD(string APZART, string APZVAR = "   ", string APZSTUFE = "F")
        {
            DataSet setReturn = new DataSet();
            DataSet setLocal = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            try
            {
                APZVAR = Left(APZVAR + "   ", 3);
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM APZUORD WHERE APZART=:APZART AND APZVAR=:APZVAR AND APZSTUFE=:APZSTUFE";
                or1.Parameters.Add("APZART", OracleType.NVarChar).Value = APZART;
                or1.Parameters.Add("APZVAR", OracleType.NVarChar).Value = APZVAR;
                or1.Parameters.Add("APZSTUFE", OracleType.NVarChar).Value = APZSTUFE;
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "APZUORD";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
      
        public void SaveSetDispo(DataTable tbDispo)
        {
            DataSet setDispo = new DataSet();  
            try
            {
                setDispo.Merge(tbDispo);
                string filePath = Path.Combine(PathHelper.ApplicationPath, @"Report\Interface\DATADISPO.XML");
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.File.Delete(filePath);
                    setDispo.WriteXml(filePath);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        } 
        
    }
}
